Previous Book Contents Book Index Next

Inside Macintosh: Open Transport /
Chapter 3 - Endpoints / Endpoints Reference
Constants and Data Types


The TUnitData Structure

You use the TUnitData structure to describe the data being sent with the OTSndUData function (page 3-101) and the data being read with the OTRcvUData function (page 3-105); you pass this structure as a parameter to each of these functions.

The TUnitData structure is defined by the TUnitData type.

struct TUnitData
   {  TNetbuf  addr;
      TNetbuf  opt;
      TNetbuf  udata;
   };
typedef struct TUnitData TUnitData;
Field Description
addr
A TNetbuf structure that contains information about an address.
In the udata parameter to the OTSndUData function, this field specifies the location and size of the destination address. You must allocate a buffer to hold the address and initialize the addr.buf field to point to that buffer. You must set the addr.len field to the length of the address.
In the udata parameter to the OTRcvUData function, on return, this field specifies the location and size of the address of the endpoint that has sent the data. You must allocate a buffer to contain the address, initialize the addr.buf field to point to it, and set the addr.maxlen field to specify its maximum size.
opt
A TNetbuf structure that contains information about options.
In the udata parameter to the OTSndUData function, this field specifies the location and size of options. You must allocate a buffer to hold the options and initialize the opt.buf field to point to that buffer. You must set the opt.len field to the length of the options buffer. If you do not want to specify any options, set the opt.len field to 0.
In the udata parameter to the OTRcvUData function, on return, this field contains any association-related options specified by the endpoint sending data. To read these options, you must allocate a buffer into which the provider can place the options; you must set the opt.buf field to point to the buffer; and you must set the opt.maxlen field to the maximum size of the buffer.
udata
A TNetbuf structure that contains information about the data being transferred.
In the udata parameter to the OTSndUData function, this field specifies the location and size of the buffer containing the data to be sent. You must allocate a buffer for the data and initialize the udata.buf field to point to that buffer. You must set the udata.len field to the size of the data being sent.
If you are sending data that is not stored contiguously, the udata.buf field is a pointer to an OTData structure that describes the first data fragment. In this case, you must set the udata.len field to the constant kNetbufDataIsOTData.
In the udata parameter to the OTRcvUData function, this field specifies the location and size of the buffer into which the data being received is going to be placed when the function returns. You must allocate a buffer for the data, set the udata.buf field to point to it, and set the udata.maxlen field to the maximum length of this buffer.
If you are doing a no-copy receive, the udata.buf field is a pointer to an OTBuffer pointer. In this case, you must set the udata.maxlen field to the constant kNetbufDataIsOTBufferStar.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 AUG 1996